<?php
require_once("../../../config.inc.php");
require_once("../../../app/_inc/include.php");
require_once "./_inc/funcFunction.php";

$errMsg = "";
//carico l'elenco delle funzioni
$sSQL = "SELECT f.*, l.library AS lib, l.description AS lib_des, l.note AS l_note, fv.name " .
		" FROM library l " .
		" LEFT JOIN function f ON f.library = l.library " .
		" LEFT JOIN function_variable fv ON f.function = fv.function " .
		" WHERE l.library = '".$_REQUEST['lbr']."' " .
		" ORDER BY f.category, f.function, fv.sequence ";

$query = $objSDAO->query($sSQL, "sel");
$row = $objSDAO->fetch("sel");
//output HTML
$aOpz = array("kMenu"=>'pro.fun');
echo(headerHTML($aOpz));
echo(bodyHTML($aOpz));

echo getLibHeader(sxREQ('lbr'),true);

$aCmd = array("ins"=>array("pag"=>"functionIns.php?lbr=".sxREQ('lbr'),
										"title"=>_t("new function"),
										"text"=>_t("new function"),
										"perm"=>"newfun"),
					"back"=>array()
					);
$sCmd = commandsHTML($aCmd);	
echo $sCmd;

echo("<table class='tabl01' width=\"100%\" cellpadding=\"3\" cellspacing=\"2\">\n");
echo("<tr>" .
		"<td class=\"titl01\" colspan=\"4\">List of functions</td>" .
	"</tr>\n");
echo("<tr>" .
		"<td class=\"tabh01\" width=\"10%\">Category</td>" .
		"<td class=\"tabh01\" width=\"20%\">Function</td>" .
		"<td class=\"tabh01\" width=\"60%\">Description</td>" .
		"<td class=\"tabh01\" width=\"10%\">Language</td>" .
	"</tr>\n");	
$oldCat = '';
$aLang = getLanguages();
while($row){
	if (empty($row['function'])) { break;}
	if ($oldCat != $row["category"]) {
		$oldCat = $row["category"];
		$catX = sxHE($row["category"]);
	} else {
		$catX = '&nbsp;';
	}
	$function = $row["function"];
	$descr = $row["description"];
	$lang = $row["language"];
	$sep = '';
	$sPar = '(';
	while($row and $function == $row["function"]) {
		$sPar .= $sep.$row["name"];
		$sep = ', ';
		$row = $objSDAO->fetch("sel");
	}
	$sPar .= ')';
	echo("<tr>" .
			"<td class=\"text01\" valign='top'>$catX</td>" .
			"<td class=\"text01\" valign='top'><a class=\"text01\" ".
				goToPag("functionView.php?func=".htmlspecialchars($function)."&xsn=".XSN).
				" title=\""._t("visualizza la funzione ")."'".sxHE($descr)."'\"><b>@".
				$function."</b>".$sPar."</a></td>\n" .
			"<td class=\"text01\" valign='top'>".sxHE($descr)."</td>" .
			"<td class=\"text01\" valign='top'>".sxHE($aLang[$lang])."</td>" .
		"</tr>\n");
}
echo("</table>\n");
echo $sCmd;
echo(footerHTML());
exit();
